import request from '@/assets/utils/request'
import type {AxiosPromise} from 'axios'


/**
 * 短信验证码发送
 * @param mobile 手机号码
 */
export const sendCode = (mobile: string): AxiosPromise => request.get('login/code', {mobile})

/**
 * 账号密码登录接口
 * @param username 用户名
 * @param pwd 密码
 */
export const userLogin = (username: string, pwd: string): AxiosPromise =>
  request.post('login', {account: username, password: pwd})

/**
 * 短信验证码登录接口
 * @param mobile 手机号
 * @param code 验证码
 */
export const msgLogin = (mobile: string, code: string): AxiosPromise =>
  request.post('login/code', {mobile, code})

/**
 * QQ 登录
 * @param unionId 三方标识
 * @param source 登录源   1为pc
 */
export const QQLogin = (unionId: string, source: number = 1): AxiosPromise =>
  request.post('login/social', {unionId, source})